# Build recipe for nicotine-plus.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=nicotine-plus
version=1.4.1
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/networking"

tarname=${version}.tar.gz

# Remote source(s)
fetch=https://github.com/Nicotine-Plus/nicotine-plus/archive/"$tarname"

description="
A graphical client for the SoulSeek peer-to-peer system.

Nicotine-plus is an attempt to keep Nicotine working with the latest
libraries, kill bugs, keep current with the Soulseek protocol and add
some new features that users want and/or need.
"

homepage=http://nicotine-plus.org/
license="GPLv3"

# Source documentation
docs="AUTHORS.md COPYING MANIFEST.in NEWS README.md"
docsdir="${docdir}/${program}-${version}"

echo TEST 
build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"
    
    # replace "import gobject" with: 
    # from gi.repository import GObject as gobject
    python2 setup.py build
    python2 setup.py install --prefix=/usr --root="$destdir" --optimize=1
    done


    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}/"
}


